n=int(input())
for i in range(n):
    Str=input()
    Len=len(Str)
    blank=0
    start=0
    for j in range(Len):
        if Str[j]=='\t':
            blank+=4
        else:
            if Str[j]==' ':
                blank+=1
            else:
                start=j
                break
    while blank%4>0:
        blank+=1
    for j in range(blank):
        print(" ",end='')
    for j in range(start,Len):
        print(Str[j],end='')
        if Str[j]=='#' and j<Len-1 and Str[j+1]!=' ':
            print(" ",end='')
    print()